// Copyright (c) 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/**
*@describe:
*@author wfl19/Kristas
*@date 2021/04/14
 */

package console

import "fmt"

const (
	Reset       = iota
	Red         //红
	RedBold     //红粗
	Green       //绿
	GreenBold   //绿粗
	Yellow      //黄
	YellowBold  //黄粗
	Blue        //蓝
	BlueBold    //蓝粗
	Magenta     //紫
	MagentaBold //紫粗
	Cyan        //深绿
	CyanBold    //深绿粗
	White       //白
	WhiteBold   //白粗
)

var colorMap = map[int]string{
	Reset:       "\033[0m",
	Red:         "\033[31m",   //红
	RedBold:     "\033[31;1m", //红粗
	Green:       "\033[32m",   //绿
	GreenBold:   "\033[32;1m", //绿粗
	Yellow:      "\033[33m",   //黄
	YellowBold:  "\033[33;1m", //黄粗
	Blue:        "\033[34m",   //蓝
	BlueBold:    "\033[34;1m", //蓝粗
	Magenta:     "\033[35m",   //紫
	MagentaBold: "\033[35;1m", //紫粗
	Cyan:        "\033[36m",   //深绿
	CyanBold:    "\033[36;1m", //深绿粗
	White:       "\033[37m",   //白
	WhiteBold:   "\033[37;1m", //白粗
}

func Draw(color int, s string) string {
	return fmt.Sprintf("%s%s%s", colorMap[color], s, colorMap[Reset])
}

func Drawf(color int, s string, args ...interface{}) string {
	s = fmt.Sprintf(s, args...)
	return fmt.Sprintf("%s%s%s", colorMap[color], s, colorMap[Reset])
}

func Drawln(color int, s string) string {
	return fmt.Sprintf("%s%s%s\n", colorMap[color], s, colorMap[Reset])
}